<template>
  <div>
    <h2>----------HelloModules组件的内容----------</h2>
    <h3>{{nameMessage}}：{{$store.state.a.name}}</h3>
    <h3>{{gettersUpdataname}}：{{$store.getters.fullName}}</h3>
    <h3>{{$store.getters.fullName2}}</h3>
    <h3>{{$store.getters.fullName3}}</h3>

    <button @click="updataName('李四')">模块中的mutations修改name</button>
    <button @click="modules_actionsUpdataName('杨千嬅')">模块中的actions修改name</button>
  </div>
</template>

<script>
import * as type from '../store/mutations-types'

export default {
  name: 'HelloModules',
  data(){
    return{
      nameMessage: 'moduleA里面的name',
      gettersUpdataname: 'modules中的getters中计算name'
    }
  },
  methods:{
    updataName(name){
      this.$store.commit({
        type: type.UPDATANAME,
        name
      })
    },
    modules_actionsUpdataName(name){
      this.$store.dispatch({
        type: 'modules_actionsUpdataName',
        name
      }).then(res=>{console.log(res);});
    },
  },
}
</script>

<style>

</style>